//
//  M1GenderViewController.m
//  NewMarryU
//
//  Created by apple on 2018/7/12.
//  Copyright © 2018年 Cedar. All rights reserved.
//

#import "M1GenderViewController.h"

@interface M1GenderViewController ()
@property (nonatomic ,strong) UIButton *m1_sbtn;
@end

@implementation M1GenderViewController
-(void)m1_btnClick:(UIButton *)sender{
    [UIView animateWithDuration:0.2 animations:^{
        sender.backgroundColor = [UIColor m1_colorHex:0xFFF4F4];
        sender.layer.borderColor = [UIColor m1_colorHex:0xFF385D].CGColor;
        sender.layer.borderWidth = 2;

    } completion:^(BOOL finished) {
        [M1SaveTool m1_saveGender:sender.tag==0?@"1":@"0"];
        [UIApplication sharedApplication].delegate.window.rootViewController = [M1TabBarController new];
    }];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    UILabel *m1_lb1 = [[UILabel alloc]init];
    m1_lb1.text = @"您的性别";
    m1_lb1.font = m1_font(25);
    m1_lb1.textColor = [UIColor m1_colorHex:0x333333];
    [self.view addSubview:m1_lb1];
    
    [m1_lb1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.offset(170);
    }];
    
    UILabel *m1_lb2 = [[UILabel alloc]init];
    m1_lb2.text = @"让你的匹配更加精准~";
    m1_lb2.font = m1_font(16);
    m1_lb2.textColor = m1_line_color;
    [self.view addSubview:m1_lb2];
    
    [m1_lb2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.top.equalTo(m1_lb1.mas_bottom).offset(14);
    }];float with = 150;
    if (SCREENWIDTH == 320) {
        with = 130;
    }
    
    float left = (SCREENWIDTH - with*2-17)/2;
    for (int i = 0; i<2; i++) {
        UIButton *m1_btn = [UIButton buttonWithType:UIButtonTypeCustom];
        m1_btn.tag = i;
        m1_btn.backgroundColor = [UIColor whiteColor];
        m1_btn.layer.cornerRadius = 13;
        [m1_btn addTarget:self action:@selector(m1_btnClick:) forControlEvents:UIControlEventTouchUpInside];
        m1_btn.layer.shadowColor = [UIColor m1_colorHex:0xCAD0DC].CGColor;
        m1_btn.layer.shadowOpacity = 0.25;
        m1_btn.layer.shadowOffset = CGSizeMake(1, 1);
        [self.view addSubview:m1_btn];
        UIImageView *m1_view = [[UIImageView alloc]init];
        m1_view.image = i == 0?[UIImage imageNamed:@"login_woman"]:[UIImage imageNamed:@"login_man"];
        [m1_btn addSubview:m1_view];
        [m1_view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(m1_btn);
            make.centerY.equalTo(m1_btn).offset(-10);
        }];
        
        UILabel *m1_lb = [[UILabel alloc]init];
        m1_lb.textColor = [UIColor m1_colorHex:0xC7C7C7];
        m1_lb.text = i == 0?@"女":@"男";
        m1_lb.font = m1_font(16);
        [m1_btn addSubview:m1_lb];
        [m1_lb mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(m1_btn);
            make.top.equalTo(m1_view.mas_bottom).offset(10);
        }];
       
        [m1_btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.offset(left+(with+17)*i);
            make.top.equalTo(m1_lb2.mas_bottom).offset(75);
            make.width.height.mas_offset(with);
        }];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
